﻿Public Class BasePage
    Inherits Page
    Implements IBasePage

    Public Sub NeedUpdate(ByVal sender As Object, ByVal e As EventArgs) Implements IBasePage.NeedUpdate
        For Each control As Control In Me.Controls
            If TypeOf control Is BaseUserControl Then
                CType(control, BaseUserControl).Update(sender, e)
            Else
                RaiseChildsUpdateEvent(control, sender, e)
            End If
        Next
    End Sub

    Private Sub RaiseChildsUpdateEvent(ByVal parentControl As Control, ByVal sender As Object, ByVal e As EventArgs)
        For Each control As Control In parentControl.Controls
            If TypeOf control Is BaseUserControl Then
                CType(control, BaseUserControl).Update(sender, e)
            Else
                RaiseChildsUpdateEvent(control, sender, e)
            End If
        Next
    End Sub

End Class